Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
@salesforce/ts-sinon
Advanced tools
This is a simple library to help create stubs with Sinon when working with TypeScript in order to leverage Sinon stubs and the type system more completely together as one without resorting to ugly, untyped hacks like casting stubbed functions to any
or using associative array accesses, neither of which provide IDE-autocompletion of stub properties and methods, nor work well with stricter tsc
and tslint
rules applied to test sources.
The API consists of the following functions:
Used to provide a fully stubbed interface backed by an optional set of member properties which may form a subset of the overall interface. Function properties will be typed as proper SinonStub
s along with any other specific type information provided by the interface.
Returns a fully stubbed proxy similar to those provided by stubInterface
, but backed first by the optionally given members, and finally by a given object. This is useful for stubbing some properties of an existing object while providing test-specific returns for fakes for others.
Like stubObject
but works with callable TypeScript function types (i.e., functions with properties).
When using stubObject
with objects created from classes with non-public members, the resulting StubbedType<T>
often needs to be passed to a function or constructor that expects a T
, but TypeScript's mapped types (which are the basis of StubbedType
) do not capture non-public class members. Since the StubbedType
returned from stubObject
is backed by a real instance of type T
, it can be simply reverted to type T
by using fromStub(instance)
. The implementation of this simply applies a type assertion, but using fromStub
is preferred for clarity, especially given that this library exists to reduce the necessity of using type assertions in tests in the first place.
FAQs
TypeScript helpers for Sinon
The npm package @salesforce/ts-sinon receives a total of 27,981 weekly downloads. As such, @salesforce/ts-sinon popularity was classified as popular.
We found that @salesforce/ts-sinon demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.